package com.wangyb.wework.service.contact;

import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;

/**
 * @Author: wangyb
 * @Date: 2021/7/4 2:34 下午
 */
@Data
public class SyncContactSummary extends AbstractSyncSummary{

	private int employeeCnt;
	private int localContactCnt;
	private int remoteContactCnt;
	private int remoteContactDetailCnt;



	private int localContactEmployeeCnt;
	private int remoteContactEmployeeCnt;
	private int addContactEmployeeCnt;
	private int updateContactEmployeeCnt;
	private int deleteContactEmployeeCnt;

	private int addContactCnt;
	private int updateContactCnt;
	private int deleteContactCnt;

	@Setter(AccessLevel.NONE)
	private SyncTagPivotSummary tagPivotSummary;

	public void addSyncTagPivotSummary(SyncTagPivotSummary summary){
		if (this.tagPivotSummary == null){
			this.tagPivotSummary = new SyncTagPivotSummary();
		}
		this.tagPivotSummary.increaseAddTagPivotCnt(summary.getAddTagPivotCnt());
		this.tagPivotSummary.increaseDeleteTagPivotCnt(summary.getDeleteTagPivotCnt());
		this.tagPivotSummary.increaseUpdateTagPivotCnt(summary.getUpdateTagPivotCnt());
		this.tagPivotSummary.increaseLocalTagPivotCnt(summary.getLocalTagPivotCnt());
		this.tagPivotSummary.increaseRemoteTagPivotCnt(summary.getRemoteTagPivotCnt());
	}

	@Data
	static class SyncTagPivotSummary{
		private int localTagPivotCnt;

		private int remoteTagPivotCnt;
		private int addTagPivotCnt;
		private int updateTagPivotCnt;
		private int deleteTagPivotCnt;

		private void increaseLocalTagPivotCnt(int localTagPivotCnt){
			this.localTagPivotCnt += localTagPivotCnt;
		}
		private void increaseRemoteTagPivotCnt(int remoteTagPivotCnt){
			this.remoteTagPivotCnt += remoteTagPivotCnt;
		}
		private void increaseAddTagPivotCnt(int addTagPivotCnt){
			this.addTagPivotCnt += addTagPivotCnt;
		}
		private void increaseUpdateTagPivotCnt(int updateTagPivotCnt){
			this.updateTagPivotCnt += updateTagPivotCnt;
		}
		private void increaseDeleteTagPivotCnt(int deleteTagPivotCnt){
			this.deleteTagPivotCnt += deleteTagPivotCnt;
		}
	}

	@Override
	public String toString() {
		if (this.tagPivotSummary == null){
			this.tagPivotSummary = new SyncTagPivotSummary();
		}
		String rn = "\n";
		return "本次共有"+employeeCnt+"个成员需要同步"+rn+
			"联系人:本地共有:"+localContactCnt+",远端有:"+remoteContactCnt+",获取详情有:"+remoteContactDetailCnt +rn+
			"           更新情况为:新增"+addContactCnt+",更新:"+updateContactCnt+",删除:"+deleteContactCnt +rn+
			"联系人成员关系:本地有"+localContactEmployeeCnt+",远端有:"+remoteContactEmployeeCnt+rn+
			"           更新情况为:新增"+addContactEmployeeCnt+",更新:"+updateContactEmployeeCnt+",删除:"+deleteContactEmployeeCnt +rn+
			"标签:本地有:"+tagPivotSummary.localTagPivotCnt+",远端有:"+tagPivotSummary.remoteTagPivotCnt+rn+
			"           更新情况为:新增"+tagPivotSummary.addTagPivotCnt+",更新:"+tagPivotSummary.updateTagPivotCnt+",删除:"+tagPivotSummary.deleteTagPivotCnt +rn;
	}
}
